home *** CD-ROM | disk | FTP | other *** search
- Path: netnews1.apci.com!usenet
- From: wardmw@apci.com (Martin Ward)
- Newsgroups: comp.lang.c
- Subject: Re: Leap Years
- Date: Fri, 01 Mar 1996 07:56:02 GMT
- Organization: Air Products Europe
- Message-ID: <4h6ara$mu@netnews1.apci.com>
- References: <8BA8405.02C70020E1.uuout@sourcebbs.com>
- Reply-To: wardmw@apci.com
- NNTP-Posting-Host: p1862.apci.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- david.mohorn@sourcebbs.com (DAVID MOHORN) typed:
-
- >How do you feature out leap years? If its evenly divisible by 400 and
- >4?
-
- The following code will do it:
-
- /* Return TRUE if iYear is a leap year, otherwise return FALSE */
-
- int IsLeapYear(int iYear)
- {
- /* Check for a 4000th year */
- if ( (iYear % 4000) == 0)
- return FALSE;
-
- /* Check for 400th year */
- if ( (iYear % 400) == 0)
- return TRUE;
-
- /* Check for century */
- if ( (iYear % 100) == 0 )
- return FALSE;
-
- /* C
- if ( (iYear % 4) == 0 )
- return TRUE;
-
- return FALSE;
- }
-
- HTH.
-
- |\/|
-
-